/**
 * 2010(c) Copyright Oceansoft Information System Co.,LTD. All rights reserved.
 * <p>
 * Compile: JDK 1.6+
 * <p>
 * 版权所有(C)：江苏欧索软件有限公司
 * <p>
 * 公司名称：江苏欧索软件有限公司
 * <p>
 * 公司地址：中国苏州科技城青山路1号
 * <p>
 * 网址: http://www.oceansoft.com.cn
 * <p>
 * 作者: 090922(陈伟)
 * <p>
 * 文件名: com.oceansoft.mobile.econsole.modules.client.controller.MobileClientController.java 
 * <p>
 * 类产生时间: 2014-6-16 0016 下午 14:34
 * <p>
 * 负责人: 090922(陈伟)
 * <p>
 * Email:javacspring@gmail.com
 * <p>
 * 所在组 : 掌上公安应用平台
 * <p>
 * 所在部门: 开发部--手持技术部
 * <p>
 * <p>
 */
package com.oceansoft.mobile.econsole.modules.member.controller;

import com.oceansoft.mobile.econsole.modules.base.controller.BaseController;
import com.oceansoft.mobile.econsole.modules.base.entity.Pager;
import com.oceansoft.mobile.econsole.modules.base.entity.Query;
import com.oceansoft.mobile.econsole.modules.base.entity.Result;
import com.oceansoft.mobile.econsole.modules.channel.entity.Channel;
import com.oceansoft.mobile.econsole.modules.log.entity.SysBlackLog;
import com.oceansoft.mobile.econsole.modules.log.service.IBlackLogService;
import com.oceansoft.mobile.econsole.modules.member.entity.Member;
import com.oceansoft.mobile.econsole.modules.member.service.IMemberService;
import com.oceansoft.mobile.econsole.modules.sys.entity.SysUser;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

/**
 * 注册用户管理控制器
 *
 * @author: chenw
 * @time: 2014-6-16 0016 下午 14:34
 */
@Controller
@RequestMapping("member")
public class MemberController extends BaseController {

    @Resource
    private IBlackLogService blackLogService;

    @Resource
    private IMemberService memberService;

    @RequestMapping("index")
    public String gotoIndex(Query query, Model model) {
        model.addAttribute("query", query);
        model.addAttribute("pager", memberService.findByPage(query));
        log("查看客户端用户列表");
        return "member/member-list";
    }

    /**
     * 列表分页显示
     *
     * @param query 分页查询条件
     * @param model 数据Model
     * @return 页面地址
     */
/*    @RequestMapping(value = "list", method = POST)
    public String loadPageByCondition(Query query, Model model) {
        Pager<Member> pager = memberService.findByPage(query);
        model.addAttribute("query", query);
        model.addAttribute("pager", pager);
        log(String.format("查看系统用户第%dÎ页", query.getPageNum()));
        return "member/member-list";
    }*/

    /**
     * 查看用户详细信息
     *
     * @param memberId 注册用户ID
     * @param model    Model
     * @return String
     */
/*    @RequestMapping(value = "view/{member_id}", method = GET)
    public String viewMemberInfo(@PathVariable("member_id") int memberId, Model model) {
        if (1 > memberId) {
            return "member/member-view";
        } else {
            Member member = memberService.findMemberById(memberId);
            model.addAttribute("member", member);
            return "member/member-edit";
        }
    }*/

    /**
     * 更新用户信息
     *
     * @param member
     * @return
     */
/*    @ResponseBody
    @RequestMapping(value = "edit", method = POST)
    public Result editMember(Member member) {
        memberService.update(member);
        log(String.format("更新用户信息[ %s ]，ID=%d", member.getLoginId(), member.getId()));
        return new Result();
    }*/


    /**
     * 跳转到状态更新
     * @param memberId
     * @param model
     * @return
     */
/*    @RequestMapping(value = "change/{member_id}", method = GET)
    public String changeMember(@PathVariable("member_id") int memberId, Model model) {
        model.addAttribute("member", memberService.findMemberById(memberId));
        return "member/member-change";
    }*/



/*    @ResponseBody
    @RequestMapping(value = "save", method = POST)
    public Result saveMember(Member member, SysBlackLog log) {
        Result r = new Result(Result.FAILURE, "提交参数有误");
        //用户存在
        if (null != member) {
            //更新用户信息
            r = memberService.update(member);
            //获取登录人信息
            SysUser sess = getSession();
            //添加操作人id
            log.setOperate_id(sess.getId());
            //添加操作人姓名
            log.setOperate_name(sess.getRealName());
            //添加一条新的黑名单记录
            blackLogService.addBlackLogPage(log);
            return r;
        }
        return r;
    }*/
}
